#include <mbed.h>
#ifdef TARGET_UNO_91H
#include "WiFiStackInterface.h"
// #include "baidu_wifi_ssid_config.h"
#else
#include "EthernetInterface.h"
#endif

#ifndef BD_NET_STACK_SOC_WIFI_SSID
#define BD_NET_STACK_SOC_WIFI_SSID  "Jt9Y9482" //"aaaabbbb"//
#endif

#ifndef BD_NET_STACK_SOC_WIFI_PASS
#define BD_NET_STACK_SOC_WIFI_PASS  "p1Ebh3NcbBoXbsuX" //"12345678"//"p1Ebh3NcbBoXbsuX"
#endif

//#include "baidu_upnp_ssdp.h"
#include "baidu_upnp_test.h"
#include "baidu_recorder.h"

#if defined (TARGET_UNO_91H) || defined (TARGET_UNO_81C_U04)
static WiFiStackInterface nif;
#else
static EthernetInterface nif;
#endif

void* baidu_get_netstack_instance(void) {
    return (void*)&nif;
}

int main(void) {
    int rs;
#if defined (TARGET_UNO_91H) || defined (TARGET_UNO_81C_U04)
    rs = nif.connect(BD_NET_STACK_SOC_WIFI_SSID, BD_NET_STACK_SOC_WIFI_PASS, NSAPI_SECURITY_NONE);
#else
    rs = nif.connect();
#endif

    if (rs == 0) {
        LOG("IP address is:\t%s\n", nif.get_ip_address());
        LOG("MAC address is:\t%s\n", nif.get_mac_address());
        const char* local_ip = nif.get_ip_address();
        const char* mac = nif.get_mac_address();
        //test_sspd_receive(local_ip);
        test_all_upnp_api(local_ip,mac);
        //test_gen_xml();
    } else {
        LOG("Network initial failed....");
        Thread::wait(osWaitForever);
    }
    return 0;
}
